#include <stdio.h>

int main(int argc, char const *argv[])
{
    if( argc != 2 )
    {
        printf("Pls input: ./a.out <file name to be created> \n");
        return 0;
    }

    FILE *fp = fopen( argv[1], "w+" );
    if( NULL == fp)
    {
        printf("Fail to Create File %s \n", argv[1]);
        return -1;
    }

    printf("Success to Create File %s \n", argv[1]);
    
    int iRet = fclose(fp);
    if ( 0 != iRet )
    {
        printf( "Fail fclose %s \n", argv[1] );
        return -1;
    }

    printf("Success to close File %s \n", argv[1]);

    return 0;
}

/*
函数 fopen
函数 fclose

fopen 必须对应 fclose, 
fclose的功能: 关闭指定的文件流, 刷新缓冲区.

程序进程结束时会自动对还在打开状态的文件流调用flcose, 但是主动调用fclose可以检查返回值.

*/